import React from 'react';
import { Switch } from 'antd';

type Props = {
  value?: boolean;
  onChange?: (value: number) => void;
};

const SwitchForForm: React.FC<Props> = ({ value, onChange }) => {
  return (
    <Switch
      checkedChildren="是"
      unCheckedChildren="否"
      checked={Boolean(value)}
      onChange={(e) => {
        if (onChange) {
          onChange(Number(e));
        }
      }}
    ></Switch>
  );
};

export default SwitchForForm;
